home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / title-header.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2005-06-30  |  5.4 KB  |  174 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Bump-mapped title script --- create a bump-mapped title image for web pages
  4. ; Copyright (C) 1997 Federico Mena Quintero
  5. ; federico@nuclecu.unam.mx
  6. ; ************************************************************************
  7. ; Changed on Feb 4, 1999 by Piet van Oostrum <piet@cs.uu.nl>
  8. ; For use with GIMP 1.1.
  9. ;
  10. ; The corresponding parameters have been replaced by an SF-FONT parameter.
  11. ; The call to gimp-context-set-background has been given a real layer
  12. ; (although it is not used) otherwise gimp 1.1 crashed.
  13. ; ************************************************************************
  14. ; This program is free software; you can redistribute it and/or modify
  15. ; it under the terms of the GNU General Public License as published by
  16. ; the Free Software Foundation; either version 2 of the License, or
  17. ; (at your option) any later version.
  18. ; This program is distributed in the hope that it will be useful,
  19. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ; GNU General Public License for more details.
  22. ; You should have received a copy of the GNU General Public License
  23. ; along with this program; if not, write to the Free Software
  24. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26.  
  27. (define (script-fu-title-header text
  28.                 size
  29.                 fontname
  30.                 gradient-reverse)
  31.   (let* (; Parameters
  32.      
  33.      (padding 8)
  34.      (fade-width 64)
  35.  
  36.      ; Image 
  37.  
  38.      (img (car (gimp-image-new 256 256 RGB)))
  39.  
  40.      ; Text layer
  41.  
  42.      (text-layer (car (gimp-text-fontname
  43.                img
  44.                -1
  45.                0
  46.                0
  47.                text
  48.                padding
  49.                TRUE
  50.                size
  51.                PIXELS
  52.                fontname)))
  53.      (text-width (car (gimp-drawable-width text-layer)))
  54.      (text-height (car (gimp-drawable-height text-layer)))
  55.  
  56.      ; Sizes
  57.  
  58.      (text-layers-offset (/ text-height 2))
  59.  
  60.      (img-width (+ text-layers-offset text-width fade-width))
  61.      (img-height text-height)
  62.  
  63.      ; Additional layers
  64.      
  65.      (bg-layer (car (gimp-layer-new img img-width img-height RGBA-IMAGE
  66.                     "bg-layer" 100 NORMAL-MODE)))
  67.      (bumpmap-layer (car (gimp-layer-new img
  68.                          text-width
  69.                          text-height
  70.                          RGBA-IMAGE
  71.                          "bumpmap-layer"
  72.                          100
  73.                          NORMAL-MODE)))
  74.      (fore-layer (car (gimp-layer-new img text-width text-height RGBA-IMAGE
  75.                       "fore-layer" 100 NORMAL-MODE))))
  76.  
  77.     (gimp-context-push)
  78.  
  79.     ; Create image
  80.  
  81.     (gimp-image-undo-disable img)
  82.     (gimp-image-resize img img-width img-height 0 0)
  83.  
  84.     (gimp-image-add-layer img bg-layer -1)
  85.     (gimp-image-add-layer img bumpmap-layer -1)
  86.     (gimp-image-add-layer img fore-layer -1)
  87. ;    (gimp-image-add-layer img text-layer -1)
  88.     (gimp-image-raise-layer img text-layer)
  89.     (gimp-image-raise-layer img text-layer)
  90.     (gimp-image-raise-layer img text-layer)
  91.     (gimp-layer-set-offsets bg-layer 0 0)
  92.     (gimp-layer-set-offsets text-layer text-layers-offset 0)
  93.     (gimp-layer-set-offsets bumpmap-layer text-layers-offset 0)
  94.     (gimp-layer-set-offsets fore-layer text-layers-offset 0)
  95.  
  96.     ; Create bumpmap layer
  97.  
  98.     (gimp-context-set-background '(0 0 0))
  99.     (gimp-edit-fill bumpmap-layer BACKGROUND-FILL)
  100.     (gimp-selection-layer-alpha text-layer)
  101.     (gimp-context-set-background '(255 255 255))
  102.     (gimp-edit-fill bumpmap-layer BACKGROUND-FILL)
  103.     (gimp-selection-none img)
  104.     (plug-in-gauss-rle 1 img bumpmap-layer 4.0 TRUE TRUE)
  105.  
  106.     ; Fore layer, bumpmap
  107.  
  108.     (gimp-context-set-background '(255 255 255))
  109.     (gimp-edit-fill fore-layer BACKGROUND-FILL)
  110.     (plug-in-bump-map 1 img fore-layer bumpmap-layer 135.0 45.0 4 0 0 0 0 FALSE FALSE 0)
  111.  
  112.     ; Text layer
  113.  
  114.     (gimp-drawable-set-visible text-layer TRUE)
  115.     (gimp-layer-set-preserve-trans text-layer TRUE)
  116.  
  117.     (gimp-edit-blend text-layer CUSTOM-MODE NORMAL-MODE
  118.              GRADIENT-LINEAR 100 0 REPEAT-NONE gradient-reverse
  119.              FALSE 0.2 3 TRUE
  120.              padding padding
  121.              (- text-width padding 1) (- text-height padding 1))
  122.  
  123.     ; Semicircle at the left
  124.  
  125.     (gimp-context-set-background '(0 0 0))
  126.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  127.  
  128.     (gimp-ellipse-select img 0 0 text-height text-height CHANNEL-OP-REPLACE TRUE FALSE 0)
  129.     (gimp-context-set-background (car (gimp-image-pick-color img text-layer
  130.                                  text-layers-offset 0
  131.                                  TRUE FALSE 0)))
  132.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  133.  
  134.     ; Fade-out gradient at the right
  135.  
  136.     (gimp-rect-select img (- img-width fade-width) 0 fade-width text-height
  137.               CHANNEL-OP-REPLACE FALSE 0)
  138.     (gimp-context-set-foreground (car (gimp-context-get-background)))
  139.     (gimp-context-set-background '(0 0 0))
  140.  
  141.     (gimp-edit-blend bg-layer FG-BG-RGB-MODE NORMAL-MODE
  142.              GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
  143.              FALSE 0.2 3 TRUE
  144.              (- img-width fade-width) 0 (- img-width 1) 0)
  145.  
  146.     (gimp-selection-none img)
  147.  
  148.     ; Done
  149.     
  150. ;    (gimp-image-flatten img)
  151.     (gimp-image-undo-enable img)
  152.     (gimp-display-new img)
  153.  
  154.     (gimp-context-pop)))
  155.  
  156. (script-fu-register "script-fu-title-header"
  157.             _"Web Title Header..."
  158.             "Web title header"
  159.             "Federico Mena Quintero"
  160.             "Federico Mena Quintero"
  161.             "June 1997"
  162.             ""
  163.             SF-STRING     _"Text"               "Hello world!"
  164.             SF-ADJUSTMENT _"Font size (pixels)" '(32 2 256 1 10 0 0)
  165.             SF-FONT       _"Font"               "Sans"
  166.             SF-TOGGLE     _"Gradient reverse"   FALSE)
  167.  
  168. (script-fu-menu-register "script-fu-title-header"
  169.              _"<Toolbox>/Xtns/Script-Fu/Logos")
  170.